<!--
 * @Author: your name
 * @Date: 2020-08-31 16:36:20
 * @LastEditTime: 2020-09-03 17:32:43
 * @LastEditors: Please set LastEditors
 * @Description: In User Settings Edit
 * @FilePath: \admin-management\web\src\components\custom-dialog\index.vue
-->
<template>
  <a-modal :title="title" :visible="visibleDialog" v-bind="$attrs" centered @ok="handleOk" @cancel="handleCancel">
    <slot></slot>
  </a-modal>
</template>

<script>
import { computed } from 'vue';
export default {
  name: 'CustomDialog',
  inheritAttrs: false,
  props: {
    visible: {
      type: Boolean,
      default: false
    },
    title: {
      type: String,
      default: '提示'
    }
  },
  setup(props, { emit, attrs }) {
    let visibleDialog = computed({
      get: () => props.visible,
      set: (val) => {
        emit('update:visible', false);
      }
    });

    function handleOk() {
      emit('confirm');
    }

    function handleCancel() {
      emit('close');
    }

    return {
      visibleDialog,
      handleOk,
      handleCancel
    };
  },
  created() {}
};
</script>
